package beans.thread.lululu;

/**
 * 等待线程死亡。
 * 
 * @author Jert
 * 
 */
public class MainJoinThread
{

	public static void main(String[] args)
	{

		Thread thread2 = new Thread(new WaitRunnable());
		Thread thread3 = new Thread(new WaitRunnable());

		System.out.println("Current time millis : " + System.currentTimeMillis());
		thread2.start();
		try
		{
			thread2.join();
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
		System.out.println("Current time millis : " + System.currentTimeMillis());

		thread3.start();
		try
		{
			thread3.join(1000);
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
		System.out.println("Current time millis : " + System.currentTimeMillis());
	}

	private static class WaitRunnable implements Runnable
	{

		@Override
		public void run()
		{
			try
			{
				Thread.sleep(5000);
			}
			catch (InterruptedException e)
			{
				e.printStackTrace();
			}
		}
	}
}
